<div class="am-modal  am-modal-prompt" tabindex="-1" id="order-operation" style="width:400px;">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">
            （改）派单
        </div>
        <div class="am-modal-bd am-text-sm" style="background-color:#F2F2F2">
            <div class="am-g am-text-left am-padding-top-sm">
                <div class="am-u-sm-4">
                    请选择小哥
                </div>
                <div class="am-u-sm-6">
                    <select name="worker" id="worker">
                    	
                    </select>
                </div>
                <div class="am-u-sm-2">
                </div>
            </div>
        </div>
        <div class="am-modal-footer" style="background-color:#F2F2F2">
            <div class="am-g">
                <div class="am-u-sm-4">
                    <button type="button" style="border:none" class="am-text-secondary" onclick="assign()">
                        派单
                    </button>
                </div>
                <div class="am-u-sm-4">
                    <button type="button" style="border:none" class="am-text-secondary am-modal-btn" data-am-modal-close>
 	 	关闭
                    </button>
                </div>
                <input type="hidden" name="order_id" id="order_id" value="">
            </div>
        </div>
    </div>
</div>
<style type="text/css">
    input[type = text] {
        width: 150px
    }
    
    select {
        width: 150px;
        height: 30px;
	
    }
</style>
<block name="script">
    <script type="text/javascript" src="__PUBLIC__/Common/js/jquery-2.0.3.min.js" charset="utf-8">
    </script>
    <script type="text/javascript">
        $(function(){
        	
        	Think.setValue('emergency', '{$map.emergency|default=""}');
        	Think.setValue('status', '{$map.status|default="1"}');
        });
        
        function assign(){
        	
        	var workerID = $("#worker").val();
        	var orderID = $("#order_id").val();
        	
        	if(!workerID || !orderID){
        		alert('参数错误');
        		$('#order-operation').modal('close');
        	}else{
        		var target = Think.U('Orders/dispatch');
        		$.post(target, {'worker_id':workerID, 'order_id':orderID}, function(data){
        			
        			if(data.status==1){
        				alert('操作成功');
        			}else{
        				alert('操作失败，请刷新后再试');
        			}
        			$('#order-operation').modal('close');
        		});
        	}
        }
        
    </script>
</block>
